<template>
  <div class="value-add-box">
    <h2 class="toolsTitle">增值功能</h2>
    <a-row v-for="(item, index) in childFunctionLists" :key="index">
      <a-col :span="9">
        <div class="toolItem">
          <span>{{ item.productName }}</span>
          <a-input-number
            :min="0"
            :max="100"
            :precision="2"
            v-model="item.serviceFee"
            :disabled="!item.open"
            v-if="isSuper"
          />
          <span v-else class="spanTitle"> {{ item.serviceFee }}</span>
          <span>
            {{ item.productCode === "withdraw.fee" ? "元/笔" : "%" }}</span
          >
        </div>
      </a-col>
      <a-col :span="9">
        <span>{{ item.productName }} 成本</span>
        <a-input-number
          :min="0"
          :max="100"
          :step="0.01"
          :precision="2"
          :disabled="!item.open"
          v-model="item.serviceFeeCost"
        />
        <span> {{ item.productCode === "withdraw.fee" ? "元/笔" : "%" }}</span>
      </a-col>
      <a-col :span="6" v-if="isSuper">
        <a-switch v-model="item.open"  />
      </a-col>
    </a-row>
    <div></div>
  </div>
</template>

<script>
export default {
  props: {
    FunctionLists: {
      type: Array,
      default: () => [],
    },
    isSuper: {
      type: Boolean,
      default: false,
    },
    // 是否需要返回最新的数组值 给父组件处理
    // needReturnLists: {
    //   type: Boolean,
    //   default: false,
    // },
  },
  data() {
    return {
     
      childFunctionLists: [],
      isSuccessConfig: false, // 是否配置成功
    };
  },

  created() {
    this.childFunctionLists = JSON.parse(JSON.stringify(this.FunctionLists));
  },

  methods: {
    CheckedFeeHandle() {
      // 是超级管理员 判断值的大小
      // for (var i = 0; i < this.childFunctionLists.length; i++) {
      //   var temp_data = this.childFunctionLists[i]
      //   if (this.isSuper && temp_data.serviceFeeCost > temp_data.serviceFee) {
      //     this.$message.warning(
      //       temp_data.productName + "成本" + " 必须<= " + temp_data.productName
      //     );
      //     return;
      //   }

      // }

 

      var sendData = {
        list: this.childFunctionLists,
      };


        this.$emit("getChildFun", sendData)
    
      // // 提交编辑好的 配置
      // this.$axios.post("/agent/added/value/submit", sendData).then((res) => {
      //   if (res.data.code === "OK") {
      //     this.isSuccessConfig = true;
      //     this.$emit("getChildFun", this.isSuccessConfig);
      //   } else {
      //     this.isSuccessConfig = false;
      //      this.$emit("getChildFun", this.isSuccessConfig);
      //     this.$message.error(res.data.message);
      //   }
      // });
    },

    PopAddFunction() {
      this.CheckedFeeHandle();
    },
  },
};
</script>


<style lang="less" scoped>
.toolsTitle {
  margin: 15px 0;
  font-weight: 600;
}
.spanTitle {
  margin: 0 15px;
  font-weight: 600;
}

.toolItem {
  margin: 8px 0;
}
</style>